package pokemon;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class TypeChart 
{		
	private int numTypes = Types.values().length;
	private double[][] chart = new double[numTypes][numTypes];
	private final String TYPE_CHART_LOCATION = "type_chart.txt";
	//Attacker Defender
	public TypeChart()
	{
		File file = new File(TYPE_CHART_LOCATION);
		try
		{
			Scanner reader = new Scanner(file);
			for(int i = 0; i < numTypes; i++)
			{
				for(int j = 0; j < numTypes; j++)
				{
					chart[i][j] = reader.nextDouble();
				}
			}
		}
		catch (FileNotFoundException e)
		{
			System.err.println("File not found.");
			System.exit(1);
		}
	}
	
	public double getDamageModifier(Types attackingType, Types defendingType)
	{
		return chart[attackingType.ordinal()][defendingType.ordinal()];
	}
	
	public double[][] getTypeChart()
	{
		return chart;
	}
	
	public void printChart()
	{
		for(int i = 0; i < numTypes; i++)
		{
			for(int j = 0; j < numTypes; j++)
			{
				System.out.print(chart[i][j] + " ");
			}
			System.out.println();
		}
	}
}
